package com.goldplusgold.tradedelay.app.trade.networkservice;

import android.util.Log;

import com.goldplusgold.network.lib.ApiProxyFactory;
import com.goldplusgold.tradedelay.app.trade.pojo.Customer;
import com.goldplusgold.tradedelay.app.trade.pojo.EntrustList;
import com.goldplusgold.tradedelay.app.trade.pojo.EntrustStatus;
import com.goldplusgold.tradedelay.app.trade.pojo.MyAssets;
import com.goldplusgold.tradedelay.app.trade.pojo.OrderResult;
import com.goldplusgold.tradedelay.app.trade.pojo.PositionAmount;
import com.goldplusgold.tradedelay.app.trade.pojo.PositionList;
import com.goldplusgold.tradedelay.app.trade.pojo.PositionType;
import com.goldplusgold.tradedelay.app.trade.pojo.ProfitAndLoss;
import com.goldplusgold.tradedelay.app.trade.pojo.Switch;
import com.goldplusgold.tradedelay.app.trade.pojo.TradeList;
import com.goldplusgold.tradedelay.app.trade.pojo.TriggeredRecordList;

import java.util.List;

/**
 * Created by admin on 2017/5/18.
 */

public class TradeService {
    private static TradeService sSingltone;
    private final ApiTrade mApiTrade;

    public TradeService() {
        mApiTrade = ApiProxyFactory.getProxy(ApiTrade.class);
    }

    public static synchronized TradeService getInstance() {
        if (sSingltone == null) {
            sSingltone = new TradeService();
        }

        return sSingltone;
    }


    public PositionList getPositionList(String proCode) throws Exception {
        return mApiTrade.getPositionList(proCode);
    }


    public EntrustList getEntrustList(String currentPage, String queryNum) throws Exception {
        return mApiTrade.getEntrustList(currentPage, queryNum);
    }

    public EntrustStatus getEntrustStatus(String orderNo) throws Exception {
        return mApiTrade.getEntrustStatus(orderNo);
    }

    public TradeList getTradeList(String currentPage, String queryNum) throws Exception {
        return mApiTrade.getTradeList(currentPage, queryNum);
    }


    public PositionType getTradeType(String prodCode) throws Exception {
        return mApiTrade.getTradeType(prodCode);
    }
    public List<PositionAmount> queryPositionAmount() throws Exception {
        Log.e("lf","123");
        return mApiTrade.queryPositonAmount();
    }
    public List<PositionAmount> queryPositionAmount(String prodCode) throws Exception {
        return mApiTrade.queryPositonAmount(prodCode);
    }
    public OrderResult orderTransaction(String tradeType, String prodCode, String price, String volume) throws Exception {
        return mApiTrade.orderTransaction(tradeType, prodCode, price, volume);
    }


    public MyAssets getMyAssets() throws Exception {
        return mApiTrade.getMyAssets();
    }

    public Customer getCustomer() throws Exception {
        return mApiTrade.getCustomer();
    }

    public ProfitAndLoss addProfitAndLossItem(String prodCode, String bearbullType, String sltpType,
                                              String sltpPrice, String floatPrice, String lots) throws Exception {

        return mApiTrade.addProfitAndLossItem(prodCode, bearbullType, sltpType, sltpPrice, floatPrice, lots);
    }

    public ProfitAndLoss deleteProfitAndLossItem(String id, String prodCode, String bearbullType, String sltpType) throws Exception {

        return mApiTrade.deleteProfitAndLossItem(id, prodCode, bearbullType, sltpType);
    }


    public ProfitAndLoss updateProfitAndLossItem(String id, String prodCode, String bearbullType, String sltpType,
                                                 String sltpPrice, String floatPrice, String lots) throws Exception {

        return mApiTrade.updateProfitAndLossItem(id, prodCode, bearbullType, sltpType, sltpPrice, floatPrice, lots);
    }


    public TriggeredRecordList getAllNotTriggered(String pageNo, String pageSize) throws Exception {

        return mApiTrade.getAllNotTriggered(pageNo, pageSize);
    }

    public TriggeredRecordList getAllTriggered(String pageNo, String pageSize) throws Exception {

        return mApiTrade.getAllTriggered(pageNo, pageSize);
    }

    public TriggeredRecordList getSettingTriggered(String prodCode, String bearbullType) throws Exception {

        return mApiTrade.getSettingTriggered(prodCode, bearbullType);
    }


    public Switch getSwitch() throws Exception {
        return mApiTrade.getSwitch();
    }

}
